package com.sea.demo.shiro.service.impl;

import com.github.pagehelper.PageHelper;
import com.sea.demo.shiro.domain.Role;
import com.sea.demo.shiro.mapper.RoleMapper;
import com.sea.demo.shiro.service.RoleService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: 快乐在角落里
 * @Create: 2020/11/8 2:17
 */
@Service
public class RoleServiceImpl implements RoleService {

    private final RoleMapper roleMapper;

    public RoleServiceImpl(RoleMapper roleMapper) {
        this.roleMapper = roleMapper;
    }

    @Override
    public int insert(Role role) {
        return roleMapper.insert(role);
    }

    @Override
    public int delete(Integer id) {
        return roleMapper.delete(id);
    }

    @Override
    public int update(Role role) {
        return roleMapper.update(role);
    }

    @Override
    public List<Role> select(Role role) {
        return select(role,null,null);
    }

    @Override
    public List<Role> select(Role role, Integer currentPage, Integer pageSize) {
        return select(role,currentPage,pageSize,null);
    }

    @Override
    public List<Role> select(Role role, Integer currentPage, Integer pageSize, String orderBy) {
        PageHelper.startPage(currentPage,pageSize,orderBy);
        return roleMapper.select(role);
    }

    @Override
    public Role selectOne(Integer id) {
        return roleMapper.selectOne(id);
    }

}
